package com.cyy.common.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

@Getter
@AllArgsConstructor
public enum MenuType {
    CATALOG("CATALOG", "目录"),
    MENU("MENU", "菜单"),
    BUTTON("BUTTON", "按钮"),
    EXTLINK("EXTLINK", "外链");

    private final String code;

    private final String desc;

    public static MenuType fromStr(String str) {
        if (StringUtils.isBlank(str)) {
            return null;
        }
        return valueOf(str.toUpperCase());
    }

    public static String getComponentByType(String component, MenuType type) {

        return type.equals(CATALOG) ? Constants.COMPONENT_LAYOUT : component;
    }
}
